libxc: Fix buffer length for get_suspend_file
authorIan Jackson <ian.jackson@eu.citrix.com>
Tue, 18 Mar 2014 13:45:25 +0000 (13:45 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 18 Mar 2014 13:56:47 +0000 (13:56 +0000)
commitfe1a6bc7546d006384157b6b004efdd3b9d283c5
tree007104690f9330d3be1929d2cd3c9a31f657f506
parentca57e4c9b8cb02ac8ea0fb474219163fba12bf6f
libxc: Fix buffer length for get_suspend_file

Declaring a formal parameter to have an array type doesn't result in
the parameter actually having an array type.  The type is "adjusted"
to a pointer.  (C99 6.9.1(7), 6.7.5.3.)

So the use of sizeof in xc_suspend.c:get_suspend_file was wrong.
Instead, use the #define.  Also get rid of the array size, as it is
misleading.

Newer versions of gcc warn about the erroneous code:
  xc_suspend.c:39:25: error: argument to 'sizeof' in 'snprintf' call
    is the same expression as the destination; did you mean to provide
    an explicit length? [-Werror=sizeof-pointer-memaccess]

Reported-By: Julien Grall <julien.grall@linaro.org>
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Ian Campbell <ian.campbell@citrix.com>
CC: Julien Grall <julien.grall@linaro.org>
--
v2: Actually change the declaration of buf.
tools/libxc/xc_suspend.c